<?php include_once("../../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once ("module/mod-nkeditor.php"); ?>
<?php include_once ("term-detail-function.php"); ?>

<body>

<!--顶部栏-->
<div id="topbar"> <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<? echo $now_extender ?>">

    <!--侧边栏-->
    <div id="sidebar"><?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?></div>





    <?
    //==============================================================================
    //这里开始才是平常开发需要注重的部分，其余的基本不用理会
    //==============================================================================
    ?>





    <div id="content" class="layui-form">

        <!--标题设定-->
        <?php $page_title="添加店铺"?>
        <?php include ROOT_PATH_ . '/controller/common/module/mod-page-title.php'; ?>





            <div class="detail-box <? echo $system_part ?>">

                <div class="detail-boxes term-detail-boxes layui-form">
                    <ul class="detail-boxing">
                        <form id="term_detail_form" method="post" action="term-add-function.php?sys_part=<? echo $system_part?>" enctype="multipart/form-data" name="uploadfile"   class="  layui-form-pane" >

                            <li class="mid"><label class="layui-form-label">人工编号：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_mid" size="20" value=""></div>
                <em class="explain">(填写您自己设置的编号，人工编号不作排序)</em></li>

                            <li class="name">
                                <label class="layui-form-label">店铺名称：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_name" size="20" value=""></div>
                <em class="explain">(<u style="color:red">*必填项目</u>,填写本店铺的标题)</em>
                            </li>
                            
                            <li class="en_name">
                                <label class="layui-form-label">英文店铺名称：</label>
                                <div class="layui-input-block"><input type="text" class="layui-input" name="term_en_name" size="20" value=""></div>
                                <em class="explain">(<u style="color:red">*必填项目</u>,填写本店铺英文的标题)</em>
                            </li>




<!--


                            <li class="term"><label class="layui-form-label">所属店铺：</label>

								<div class="layui-input-block">

                                <select name="term_term_id">


                                    <option value="root" selected="selected">当前所属店铺:根目录 \</option>
                                    <?
    /*
                                    $table_Suffix = $sys_term_table;
                                    $table = $table_Prefix . $table_Suffix;
                                    $sort_by = "nid";
                                    $sort_order = "desc";
                                    ?>

                                    <?php
                                    $query = mysql_query("SELECT COUNT(nid) FROM $table where interm = 'root' and belong ='$sys_belong'");
                                    $term0sum = mysql_result($query, 0);

                                    $result_term0 = mysql_query("select * from $table where interm='root' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

                                    while($row = mysql_fetch_array($result_term0))
                                    {
                                        $term0_nid[]=$row['nid'];
                                        $term0_name[]=$row['name'];
                                    }

                                    ?>
                                    <? for($i=0;$i<$term0sum;$i++) { ?>
                                        <option value="<?php echo $term0_nid[$i] ?>"> | - <?php echo $term0_name[$i] ?></option>
                                        <?
                                        $query2 = mysql_query("SELECT COUNT(nid) FROM $table where term1 = $term0_nid[$i] && interm = 'term1'  and belong ='$sys_belong'  ");
                                        $term1sum = mysql_result($query2, 0);
                                        if ($_REQUEST ['sortby']) {
                                            $sort_by = $_REQUEST ['sortby'];
                                        }
                                        $result1 = mysql_query("select * from $table where term1 = $term0_nid[$i] && interm = 'term1' and belong ='$sys_belong'  ORDER BY $sort_by ");
                                        while ($row = mysql_fetch_array($result1)) {
                                            {
                                                $term1_nid[$i][] = $row['nid'];
                                                $term1_mid[$i][] = $row['mid'];
                                                $term1_name[$i][] = $row['name'];
                                            }
                                        }
                                        ?>
                                        <?for ($ii = 0; $ii < $term1sum; $ii++) {?>
                                            <option value="<?php echo $term1_nid[$i][$ii] ?>"> |---- <?php echo $term1_name[$i][$ii] ?></option>
                                        <?php } ?>
                                    <?php }
    */ ?>


                                </select></div>
                <em class="explain">(选择本店铺对应的上级店铺，如是一级店铺，请选择“根目录”)</em></li>
-->




                  <?php 
	$sql = "select count(*) as brand_count from ".$table_Prefix."term  where publish = 1 and belong = 'brand' ";
			
	$brand_res = mysql_query($sql);
			
	$brand_count = mysql_fetch_assoc($brand_res);	
	
?>
            <div class="term layui-form-item detail">
                <label class="layui-form-label">所属品牌： </label>
                <div class="layui-input-block">
                      <?php 
						if($brand_count['brand_count'] == 0){
						?>
                            <a href="/controller/extender/brand/view/term-add.php?sys_part=brand" class="threeDbtn layui-btn ">添加品牌</a>

                            <?php
						}
						else{
						?>
                      <div style="float:left;">
                    <? include("mod-brand-select.php");?>
                  </div>
                      <em class="explain">(选择对应的分类，可多选。)</em>
                      <?php 
						}
						?>
                    </div>
              </div>      
              
              
                            <li  class="introduce"><label class="layui-form-label">店铺简介：</label>
                            	<div class="layui-input-block">
                                <textarea name="term_introduce" cols="20"></textarea></div>
                <em class="explain">(填写本店铺的店铺概述文字)</em>
                            </li>

                            <li class="icon"><label class="layui-form-label">ICON：</label>
                                <img src="/controller/common/asset/image/default-image.jpg" width="150"/>
                                </li>
                            <li class="icon"><label class="layui-form-label">上传文件：</label>
    <div class="layui-input-block"><input type="file" name="icon"  onchange="fileChange(this);"/></div>
                <em class="explain">(上传本店铺的列表图标)</em></li>
                            <br />


                            <li class="banner"><label class="layui-form-label">横幅图片：</label>
                                <img src="/controller/common/asset/image/default-image.jpg" width="150"/>
                            </li>
                            <li class="banner"><label class="layui-form-label">上传文件：</label>
    <div class="layui-input-block"><input type="file" name="banner"  onchange="fileChange(this);"/></div>
                <em class="explain">(上传本店铺的横幅Banner图片)</em></li>
                            <br />
                             <li class="banner"><label class="layui-form-label">横幅标题：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_banner_title"value=""></div>
                <em class="explain">(填写横幅标题内容)</em></li>
                
                             <li class="banner"><label class="layui-form-label">横幅链接：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_banner_url"value=""></div>
                <em class="explain">(填写横幅链接内容)</em></li>
                
                            <li class="extend_img"><label class="layui-form-label">备用图片：</label>
                                <img src="/controller/common/asset/image/default-image.jpg" width="150"/>
                                <span class="title-data">(请上传像素<? echo $first_extend_img_data[0]?>X<? echo $first_extend_img_data[1]?>符合比例的图片,格式为jpeg)</span>
                            </li>
                            <li class="extend_img"><label class="layui-form-label">上传文件：</label>
    <div class="layui-input-block"><input type="file" name="upfile2"  onchange="fileChange(this);"/></div>
                <em class="explain">(上传本店铺的备用图片)</em></li>
                            <br />


                            <li class="title"><label class="layui-form-label">网页用标题：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_title" size="20" value=""></div>
                <em class="explain">(填写浏览器标签页显示的本店铺页名称)</em></li>
                            <li class="description"><label class="layui-form-label">网页用描述：</label><div class="layui-input-block"><textarea name="term_description"></textarea></div>
                <em class="explain">(填写本店铺页描述性文字，用于搜索引擎的搜索结果显示)</em></li>
                            <li class="keyword"><label class="layui-form-label">网页用关键词：</label><div class="layui-input-block"><textarea name="term_keyword"></textarea></div>
                <em class="explain">(填写本店铺页的关键词，利于搜索引擎抓取)</em></li>
                            <li class="url"><label class="layui-form-label">网页地址：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_url" size="20" value="B<? echo date('Ymdhis') ?>"></div>
                <em class="explain">(填写本店铺页前台网址，用于伪静态设置，利于搜索引擎抓取)</em></li>
                            <br />



                            <li class="detail">
                                <label class="layui-form-label">店铺详情：</label>
                                <div class="layui-input-block"><textarea name="term_detail" style="width:800px;height:400px;visibility:hidden;">
                                </textarea></div>
                <em class="explain">(填写本店铺前台显示的详细文字介绍，默认留空)</em>
                            </li>



                            <li class="listorder"><label class="layui-form-label">列表排序：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_listorder" size="20" value="0" onkeydown="onlyNum();" onfocus="checkdefault(term_listorder)" onblur="checkempty(term_listorder)"></div>
                <em class="explain">(填写本店铺在所属前台列表下的列表排序，数字越大，排序越靠前)</em></li>

                            <li class="hotsale"><label class="layui-form-label">热销店铺：</label>


                                <div class="layui-input-block">
                                    <input name='term_hotsale' type='radio' value='1' id='hotsale_now' title="标记热销" />
                                    <input name='term_hotsale' type='radio' value='0' id='hotsale_later' checked='checked' title="取消热销" />
                                    
                                </div>
                				<em class="explain">(可标记热销店铺，将在前台添加热销店铺标识或显示热销产品店铺)</em>

                            </li>

                            <li class="recommend"><label class="layui-form-label">推荐店铺：</label>
                                <div class="layui-input-block">
                                    <input name='term_recommend' type='radio' value='1' id='recommend_now' title="确认推荐"/>
                                  
   									<input name='term_recommend' type='radio' value='0' id='recommend_later' checked='checked' title="取消推荐" />
                                    
                                </div>
                <em class="explain">(可标记推荐店铺，将在前台添加推荐店铺标识或显示推荐产品店铺)</em>
                            </li>

                            <li class="publish"><label class="layui-form-label">发布状态：</label>
                                <div class="layui-input-block">
                                    <input name='term_publish' type='radio' value='1' id="publish_now" title="立即发布"/>
                                  
    								<input name='term_publish' type='radio' value='0' id="publish_later"  checked="checked" title="暂未发布"  />
                                   
                                </div>
                <em class="explain">(选择立即发布，以上信息才能在前台显示；选择暂未发布，只对以上信息进行保存，不在前台显示)</em>
                            </li>

                            <li class="mark"><label class="layui-form-label">标记产品：</label>


                                <div class="layui-input-block">
                                    <input name='term_mark' type='radio' value='1' id='mark_now'  title="添加标记"/>
                                    
    								<input name='term_mark' type='radio' value='0' id='mark_later' checked='checked' title="取消标记"  />
                                  
                                </div>
                <em class="explain">(选择添加标记，以上信息将在前台显示；选择取消标记，以上信息不在前台显示)</em>

                            </li>

                            <li class="vip"><label class="layui-form-label">权限设置：</label>
                                <div class="layui-input-block">
                                    <input name='term_vip' type='radio' value='0' id='vip_now' checked='checked' title="游客可见"/>
                                   
   									<input name='term_vip' type='radio' value='1' id='vip_one' title="vip1可见"/>
                               
    								<input name='term_vip' type='radio' value='2' id='vip_two' title="vip2可见"/>
                                    
                                </div>
                <em class="explain">(设置会员可浏览的权限)</em>
                            </li>




                            <li class="markorder"><label class="layui-form-label">标记排序：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_markorder" size="20" value="0" onkeydown="onlyNum();" onfocus="checkdefault(term_markorder)" onblur="checkempty(term_markorder)"></div>
                <em class="explain">(填写店铺在前台列表中的排序，数字越大，排序越靠前)</em></li>


                            <li class="link"><label class="layui-form-label">链接地址：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_link" size="20" value=""></div>
                <em class="explain">(填写用于前台直接跳转的文章链接，类似于转载文章，默认留空)</em></li>
                            <li class="clickrate"><label class="layui-form-label">点击次数：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_clickrate" size="20" value="0" onkeydown="onlyNum();" onfocus="checkdefault(term_clickrate)" onblur="checkempty(term_clickrate)"></div>
                <em class="explain">(显示此店铺在前台被浏览点击的次数，亦可在由后台管理员自行设置数量)</em></li>

                            <li class="inputtime"><label class="layui-form-label">输入时间：</label>
    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_inputtime" size="20" value="<? echo date("Y-m-d H:i:s") ?>" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" class="laydate-icon"></div>
                <em class="explain">(填写店铺录入时间)</em></li>

							 <li class="layui-form-item is_disabled">
                                <label class="layui-form-label">禁止删除：</label>
                        
                                <div class="layui-input-block">
                                        <input name='term_is_disabled' type='radio' value='1'  title="禁止删除" />
                                        <input name='term_is_disabled' type='radio' value='0'  title="允许删除" />
                                    </div>
                <em class="explain">(如标记了禁止删除，列表页下面不能删除当前信息)</em>
                        
                             </li>  
							<input type="hidden" name="brand_list_json" id="brand_list_json" />
                            <div class="function">
                                <button class="layui-btn "  lay-submit type="button" lay-filter="formSub">立即提交</button>
                                <input type="reset" class="layui-btn" value="重置"/>
                            </div>
                           
                        </form>
                    </ul>
                </div>
            </div>

            <!--content端點01-->
        </div>
        <!--maincontent端點01-->
        <br class="clearfloat" />
    </div>
    <!--container端點01-->
</div>



<!--底部栏-->
<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>
<?php include ROOT_PATH_ . "/controller/modules/footer.php"; ?>


<script type="text/javascript">
    $(document).ready(function(e) {



        layui.use(['transfer', 'layer', 'util', 'form', 'tree'], function(){
            var $ = layui.$
                ,transfer = layui.transfer
                ,layer = layui.layer
                ,util = layui.util
                ,tree = layui.tree
                ,form = layui.form;



            form.on('submit(formSub)', function(data){

                if($('#brand_list').length > 0){
                    var checkbrandData = tree.getChecked('brand_list');
                    $('#brand_list_json').val(JSON.stringify(checkbrandData))
                }

                $('.layui-form-pane').submit()
            })

        });


    });

</script>

</body>
</html>
